package onlinebanking.client.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.WindowConstants;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class Sidebar extends javax.swing.JPanel {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JButton announcementsButton;
	private JButton accountBalanceButton;
	private JButton confirmTransactionButton;
	private JButton accountStatementButton;
	private JButton accountSettingsButton;
	private JButton initiateTransactionButton;

	/**
	 * parent will do the switching of panels
	 */
	private ClientPanel parent;

	/**
	 * Auto-generated main method to display this JPanel inside a new JFrame.
	 */
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.getContentPane().add(new Sidebar());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}

	public Sidebar() {
		super();
		this.parent = null;
		initGUI();
	}

	public Sidebar(ClientPanel parent) {
		super();
		this.parent = parent;
		initGUI();
	}

	private void initGUI() {
		try {
			this.setPreferredSize(new java.awt.Dimension(167, 450));
			this.setBackground(new java.awt.Color(190, 255, 174));
			this.setLayout(null);
			this.setSize(251, 450);
			this.setBounds(0, 0, 257, 444);
			{
				announcementsButton = new JButton();
				this.add(announcementsButton);
				announcementsButton.setText("ANNOUNCEMENTS");
				announcementsButton.setBackground(new java.awt.Color(87, 223,
						118));
				announcementsButton.setBounds(0, 0, 187, 75);
				announcementsButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						announcementsButtonActionPerformed(evt);
					}
				});
			}
			{
				accountBalanceButton = new JButton();
				this.add(accountBalanceButton);
				accountBalanceButton.setText("ACCOUNT BALANCE");
				accountBalanceButton.setBackground(new java.awt.Color(87, 223,
						118));
				accountBalanceButton.setBounds(0, 76, 187, 75);
				accountBalanceButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						accountBalanceButtonActionPerformed(evt);
					}
				});
			}
			{
				initiateTransactionButton = new JButton();
				this.add(initiateTransactionButton);
				initiateTransactionButton.setText("INITIATE TRANSACTION");
				initiateTransactionButton.setBackground(new java.awt.Color(87,
						223, 118));
				initiateTransactionButton.setBounds(0, 150, 187, 75);
				initiateTransactionButton
						.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								initiateTransactionButtonActionPerformed(evt);
							}
						});
			}
			{
				confirmTransactionButton = new JButton();
				this.add(confirmTransactionButton);
				confirmTransactionButton.setText("CONFIRM TRANSACTION");
				confirmTransactionButton.setBackground(new java.awt.Color(87,
						223, 118));
				confirmTransactionButton.setBounds(0, 225, 187, 75);
				confirmTransactionButton
						.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								confirmTransactionButtonActionPerformed(evt);
							}
						});
			}
			{
				accountStatementButton = new JButton();
				this.add(accountStatementButton);
				accountStatementButton.setText("STATEMENT OF ACCOUNT");
				accountStatementButton.setBackground(new java.awt.Color(87,
						223, 118));
				accountStatementButton.setBounds(0, 300, 187, 75);
				accountStatementButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						accountStatementButtonActionPerformed(evt);
					}
				});

			}
			{
				accountSettingsButton = new JButton();
				this.add(accountSettingsButton);
				accountSettingsButton.setText("ACCOUNT SETTINGS");
				accountSettingsButton.setBackground(new java.awt.Color(87, 223,
						118));
				accountSettingsButton.setBounds(0, 375, 187, 75);
				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * @return the announcementsButton
	 */
	JButton getAnnouncementsButton() {
		return announcementsButton;
	}

	/**
	 * @return the accountBalanceButton
	 */
	JButton getAccountBalanceButton() {
		return accountBalanceButton;
	}

	/**
	 * @return the confirmTransactionButton
	 */
	JButton getConfirmTransactionButton() {
		return confirmTransactionButton;
	}

	/**
	 * @return the accountStatementButton
	 */
	JButton getAccountStatementButton() {
		return accountStatementButton;
	}

	/**
	 * @return the accountSettingsButton
	 */
	JButton getAccountSettingsButton() {
		return accountSettingsButton;
	}

	/**
	 * @return the initiateTransactionButton
	 */
	JButton getInitiateTransactionButton() {
		return initiateTransactionButton;
	}

	private void announcementsButtonActionPerformed(ActionEvent evt) {
		if (parent != null) {
			System.out.println("SideBar: Announcements");
			this.parent.switchToAnnoucements();
		}
	}

	private void accountBalanceButtonActionPerformed(ActionEvent evt) {
		if (parent != null) {
			System.out.println("Sidebar: AccountBalance");
			this.parent.switchToAccountBalance();
		}
	}

	private void initiateTransactionButtonActionPerformed(ActionEvent evt) {
		if (parent != null) {
			System.out.println("Sidebar: InitTrans");
			this.parent.switchToInitiateTransaction();
		}
	}

	private void confirmTransactionButtonActionPerformed(ActionEvent evt) {
		if (parent != null) {
			System.out.println("Sidebar: ConfirmTrans");
			this.parent.switchToConfirmTransaction();
		}
	}
	
	private void accountStatementButtonActionPerformed(ActionEvent evt) {
		if (parent != null) {
			System.out.println("Sidebar: Account Statement");
			this.parent.switchToStatementOfAccount();
		}
	}

}
